import * as Sequelize from 'sequelize';
import { DataTypes, Model, Optional } from 'sequelize';

export interface replyAttributes {
  id: number;
  content: string;
  commentId: number;
  userId: number;
  replyUserId: number;
  status: number;
  read?: number;
  createdAt?: Date;
  updatedAt?: Date;
}

export type replyPk = "id";
export type replyId = reply[replyPk];
export type replyOptionalAttributes = "id" | "read" | "createdAt" | "updatedAt";
export type replyCreationAttributes = Optional<replyAttributes, replyOptionalAttributes>;

export class reply extends Model<replyAttributes, replyCreationAttributes> implements replyAttributes {
  id!: number;
  content!: string;
  commentId!: number;
  userId!: number;
  replyUserId!: number;
  status!: number;
  read?: number;
  createdAt?: Date;
  updatedAt?: Date;


  static initModel(sequelize: Sequelize.Sequelize): typeof reply {
    return reply.init({
    id: {
      autoIncrement: true,
      type: DataTypes.INTEGER.UNSIGNED,
      allowNull: false,
      primaryKey: true
    },
    content: {
      type: DataTypes.STRING(255),
      allowNull: false
    },
    commentId: {
      type: DataTypes.INTEGER,
      allowNull: false
    },
    userId: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "回复人"
    },
    replyUserId: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "被回复人ID"
    },
    status: {
      type: DataTypes.BOOLEAN,
      allowNull: false,
      comment: "0：审核中，1：审核通过，2：审核不通过，默认：1"
    },
    read: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "阅读状态，0：未阅，1：已阅，默认：0"
    }
  }, {
    sequelize,
    tableName: 'reply',
    timestamps: true,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
    ]
  });
  }
}
